package com.lib.model.login;

import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

import com.lib.model.dto.MemberDto;

public class LoginDao extends SqlMapClientDaoSupport implements ILoginDao {

	@Override
	public MemberDto getMember(MemberDto dto) {
		MemberDto ldto =null;
			ldto = (MemberDto)getSqlMapClientTemplate().queryForObject("LoginMap.getMember",dto);
		return ldto;
	}

	@Override
	public MemberDto getMyInfo(String id) {
		MemberDto dto = new MemberDto();
				dto = (MemberDto)getSqlMapClientTemplate().queryForObject("LoginMap.getmylibrary",id);
		return dto;
	}

	@Override
	public boolean updateMylibinfo(MemberDto dto) {
		int count=0;
		try {
			getSqlMapClientTemplate().update("LoginMap.updatemylib",dto);
			count=1;
		} catch (Exception e) {
			count=-1;
		}
		return count>0?true:false;
	}

	@Override
	public boolean deleteMember(String id) {
		int count=0;
		try {
			getSqlMapClientTemplate().delete("LoginMap.deleteMember", id);
			count=1;
		} catch (Exception e) {
			count=-1;
		}
		return count>0?true:false;
	}

	@Override
	public String findIdCheck(MemberDto dto) {
		String ldto = null;
			try {
				ldto = (String)getSqlMapClientTemplate().queryForObject("LoginMap.findIdCheck",dto);
			} catch (Exception e) {
			}
		return ldto;
	}

	@Override
	public MemberDto findPsCheck(MemberDto dto) {
		MemberDto ldto = null;
		try {
			ldto = (MemberDto)getSqlMapClientTemplate().queryForObject("LoginMap.findPwCheck",dto);	
			} catch (Exception e) {
			}
		return ldto;
	}

	@Override
	public boolean reMakePw(MemberDto dto) {
		int count=0;
		try {
			getSqlMapClientTemplate().queryForObject("LoginMap.upPassWord",dto);
			count=1;
			} catch (Exception e) {
			count=-1;
			}
			return count>0?true:false;
	}

}